#! /bin/bash
set -e;
if [ $# -ne 2 ];then
  echo "input vm_id y"
  exit 127
fi


vm_id=$1

mk_sure=$2

vm_info=`ps -ef|grep kvm|grep "/var/run/qemu-server/${vm_id}.pid"|grep "\-id ${vm_id} \-name" |awk '{print"pid:"$2"," $9":"$10","$11":"$12}'`

echo ${vm_info};


if [ ${mk_sure} == y ];then
    vm_pid=`echo ${vm_info}|awk -F',' '{print$1}'|awk -F ':' '{print$2}'|xargs echo -n`
    kill -9 ${vm_pid}

    echo "stop ${vm_info} succeed !"
fi;
